package com.sky.controller.user;


import com.sky.dto.UserLoginDTO;
import com.sky.result.Result;
import com.sky.service.UserService;
import com.sky.vo.UserLoginVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信app控制器
 */
@RestController
@RequestMapping("/user/user")
@Slf4j
@Api(tags = "app用户控制器")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 微信登录(day06任务三)
     * @param userLoginDTO
     * @return
     */
    @PostMapping("/login")
    @ApiOperation("微信登录")
    public Result<UserLoginVO> login(@RequestBody UserLoginDTO userLoginDTO){
        log.info("[微信登录] userDTO:{}",userLoginDTO);

        UserLoginVO userVO = userService.loginByOpenid(userLoginDTO);

        return Result.success(userVO);
    }
}
